<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Insert title here</title>
</h:head>
<h:body>
	<h:form>

		<p:selectOneMenu value="#{convenioMBean.resultado}" 
		 				 valueChangeListener="#{convenioMBean.buscarConvenios}"
		 				 onchange="submit()">
			<f:selectItem itemLabel="Selecione um orgão" itemValue=""
				noSelectionOption="true" />
			<f:selectItems value="#{convenioMBean.orgaos}" var="orgao"
				itemValue="#{orgao.id}" itemLabel="#{orgao.id} - #{orgao.nome}" />
		</p:selectOneMenu>
		
		
		<br />

		<p:dataTable value="#{convenioMBean.convenios}" var="conv">
			<p:column headerText="Id">
				<h:outputText value="#{conv.id}" />
			</p:column>
			<p:column headerText="Modalidade">
				<h:outputText value="#{conv.modalidade}" />
			</p:column>
			<p:column headerText="Data inicio vigência">
				<h:outputText value="#{conv.dataInicioVigencia}" >
				<f:convertDateTime pattern="dd/MM/yyyy"/>
				</h:outputText>
			</p:column>
			<p:column headerText="Data fim vigência">
				<h:outputText value="#{conv.dataFimVigencia}" >
					<f:convertDateTime pattern="dd/MM/yyyy"/>
				</h:outputText>
			</p:column>
			<p:column headerText="Data assinatura">
				<h:outputText value="#{conv.dataAssinatura}" >
					<f:convertDateTime pattern="dd/MM/yyyy"/>
				</h:outputText>
			</p:column>
			<p:column headerText="Data publicação">
				<h:outputText value="#{conv.dataPublicacao}" >
					<f:convertDateTime pattern="dd/MM/yyyy"/>
				</h:outputText>
			</p:column>
			<p:column headerText="Valor global" sortBy="#{conv.valorGlobal}">
				<h:outputText value="#{conv.valorGlobal}" >
					<f:convertNumber locale="pt_BR" type="currency"/>
				</h:outputText>
			</p:column>
			<p:column>
				<h:commandLink action="detalhe">
							<h:outputText value="+Ver detalhes" style="margin-left: 5px; margin-right: 5px"></h:outputText>
							<f:setPropertyActionListener value="#{conv}" target="#{convenioMBean.convenio}"/>
			    </h:commandLink>
			    </p:column>
		</p:dataTable>



		<h:outputLabel value="#{convenioMBean.resultado}" />
	</h:form>
</h:body>
</html>